﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebApp
{
    public partial class Error : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Server.GetLastError()!=null)
            {
                Response.Write("******************************Exception Start******************************<br>");
                Response.Write("错误文件："+Request.Url.AbsolutePath+"<br>");
                Response.Write("产生时间：" + DateTime.Now.ToString() + "<br>");
                ResponseError(Server.GetLastError());
                Response.Write("******************************Exception End********************************<br>");
                Server.ClearError();

            }
   
        }

        void ResponseError(Exception error)
        {
          
            Response.Write("来源："+error.Source + "<br>");
            Response.Write("-------------------------------<br>");
            Response.Write("信息：" + error.Message + "<br>");
            Response.Write("-------------------------------<br>");
            Response.Write("堆栈信息：" + error.StackTrace.Replace("\r\n", "<br>") + "<br>");
            Response.Write("====================================================<br>");

            if (error.InnerException!=null)
            {
                ResponseError(error.InnerException);
            }
        }
    }
}
